﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Bymed.SpineScan.DataModel;
using Bymed.SpineScan.DataModel.TestItem;
using Bymed.SpineScan.Service;

namespace Bymed.SpineScan.UnitTest.ServiceTest
{
    [TestFixture]
    public class TestItemFactoryTest
    {
        [SetUp]
        protected void Setup() { }

        [Test]
        public void GetAtiWithLeftPositionTest()
        {
            var testMessage = "ATI a=4 z=2";
            var testItem = TestItemFactory.GetTestItem(testMessage);

            Assert.IsInstanceOf(typeof(ScoliosisATITest), testItem);
            Assert.AreEqual(4, testItem.FirstResult);
            Assert.AreEqual(testMessage, testItem.ResultRawData);
        }

        [Test]
        public void GetAtiWithRightPositionTest()
        {
            var testMessage = "ATI a=-6 z=1";
            var testItem = TestItemFactory.GetTestItem(testMessage);

            Assert.IsInstanceOf(typeof(ScoliosisATITest), testItem);
            Assert.AreEqual(6, testItem.SecondResult);
            Assert.AreEqual(testMessage, testItem.ResultRawData);
        }

        [Test]
        public void GetKyphosisTest()
        {
            var testMessage = "Kyphosis 29";
            var testItem = TestItemFactory.GetTestItem(testMessage);

            Assert.IsInstanceOf(typeof(KyphosisTest), testItem);
            Assert.AreEqual(29, testItem.SecondResult);
            Assert.AreEqual(testMessage, testItem.ResultRawData);
        }

        [Test]
        public void GetFlexionExtensionTest()
        {
            var testMessage = "Flex s=0 b=62 f=-57";
            var testItem = TestItemFactory.GetTestItem(testMessage);

            Assert.IsInstanceOf(typeof(FlexionExtensionTest), testItem);
            Assert.AreEqual(62, testItem.FirstResult);
            Assert.AreEqual(57, testItem.SecondResult);
            Assert.AreEqual(testMessage, testItem.ResultRawData);
        }

        [Test]
        public void GetLateralBendingTest()
        {
            var testMessage = "Lateral s=1 l=42 r=-35";
            var testItem = TestItemFactory.GetTestItem(testMessage);

            Assert.IsInstanceOf(typeof(LateralBendingTest), testItem);
            Assert.AreEqual(42, testItem.FirstResult);
            Assert.AreEqual(35, testItem.SecondResult);
            Assert.AreEqual(testMessage, testItem.ResultRawData);
        }

        [Test]
        public void GetRotationTest()
        {
            var testMessage = "Rotation s=1 l=-71 r=38";
            var testItem = TestItemFactory.GetTestItem(testMessage);

            Assert.IsInstanceOf(typeof(RotationTest), testItem);
            Assert.AreEqual(71, testItem.FirstResult);
            Assert.AreEqual(38, testItem.SecondResult);
            Assert.AreEqual(testMessage, testItem.ResultRawData);
        }
    }
}
